import { getUserPageSelect } from '@/api/users'
import { ref } from 'vue'
import { UserPageSelect } from '../types'

// 加载
const loading = ref(false)

// 下拉选项数据
const userPageOptional = ref<Array<UserPageSelect>>([])

/**
 * 获取方法
 * @param {string} factoryId - 关联商家
 * @param {string} name - 关键字
 */
const get = async (factoryId: string, name: string) => {
  loading.value = true
  const param = {
    factoryId: factoryId ? factoryId : null,
    limit: 0,
    name: name ? name : null,
    page: 0,
  }
  const res = await getUserPageSelect(param)
  userPageOptional.value = res.data.data.rows
  loading.value = false
}

export default {
  loading,
  userPageOptional,
  get,
}
